﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NiceManage.Models;
using SqlSugar;
namespace NiceManage.Common
{
    public class Article
    {
        SqlSugarClient db = DbHelper.GetInstance();
        public int AddArticle(m_article m_Article)
        {
            return db.Insertable<m_article>(m_Article).ExecuteCommand();
        }
        public int UpdateArticle(m_article m_Article)
        {
            return db.Updateable<m_article>(m_Article).ExecuteCommand();
        }

        public int DeleteArticle(int ID)
        {
            return db.Deleteable<m_article>().Where(a => a.ID == ID).ExecuteCommand();
        }

        public List<m_article> GetList()
        {
            return db.Queryable<m_article>().ToList();
        }
        /// <summary>
        /// 根据ID查询单条
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public m_article GetM_ArticleByID(int ID)
        {
            return db.Queryable<m_article>().Where(a => a.ID == ID).First();
        }
    }
}
